package br.ucb.cm.main.common;

import br.ucb.cm.board.ui.BoardPane;
import br.ucb.cm.board.util.BoardUtil;
import br.ucb.cm.config.bean.PieceConfig;
import br.ucb.cm.main.common.GeneralConstants.PlayerEnum;
import br.ucb.cm.main.mainview.GameController;

public class HumanController extends PlayerController{

	public HumanController(GameController gameController, BoardPane boardPane, PlayerEnum player) {
		super(gameController, boardPane, player);
	}

	@Override
	public Object doAction(ActionEnum action) {
		Object object = super.doAction(action);

		return object;
	}

	@Override
	public void useAsController() {
		super.useAsController();
		boardPane.setCursor(null);
		
		if(!isThereMovements)
			setCanUseBoard(false);
		else
			setCanUseBoard(true);
	}

	
	
	@Override
	public Object doAction(ActionEnum action, Object object) {
		super.doAction(action, object);
		
		switch (action) {
		case MOVE:
			setCanUseBoard(false);
			break;
		case VALIDATE:
			return player == BoardUtil.getOwner((PieceConfig)object);
		default:
			break;
		}
		
		return null;
	}

}
